#include <stdio.h>
#include <algorithm>
using namespace std;

#define rep(i,n) for (int i=0; i<n; i++)

#define TRACE(x...) x
#define PRINT(x...) TRACE(printf(x))

int n, m;
int sets[110];
int sum;

int main() {
	scanf("%d %d", &n, &m);

	rep(i,n) scanf("%d", &sets[i]);
	sort(sets, sets+n);

	sum=0;

	rep(i,m) {
		if (sets[i]>0) break;
		else sum+=(-sets[i]);
	}

	printf("%d\n", sum);

	return 0;
}
